package com.hxx.day5.hxx;

import org.junit.Test;

import java.util.UUID;

public class TestDemo2 {

    @Test
    public void test1() throws Exception {
        String str1 = "123";
        String str2 = "123";
        String str3 = str1+""+str2;
    }
    @Test
    public void test2() throws Exception {
        String str1 = "123";
        String str2 = new String("123");

        System.out.println(str1.equals(str2));
    }
    @Test
    public void test3() throws Exception {
        String str1 = "abc";
        String str2 = new String("Abc");

        System.out.println(str1.equalsIgnoreCase(str2));

        String str3 = "abc";
        System.out.println(str3.toUpperCase());
    }
    @Test
    public void test4() throws Exception {
        String str1 = "abc.hello.txt";
        System.out.println(str1.indexOf("."));
    }
    @Test
    public void test5() throws Exception {
        String str1 = "abc.hello.txt";
        System.out.println(str1.lastIndexOf("."));
        System.out.println(str1.substring(str1.lastIndexOf(".")));
        System.out.println(UUID.randomUUID().toString()+str1.substring(str1.lastIndexOf(".")));
    }

    @Test
    public void test6() throws Exception {
        String str1 = "java,mysql,spring,springboot";
        String[] arr = str1.split(",");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }

    /**
     * \d \w \s \W \D \S
     * @throws Exception
     */
    @Test
    public void test7() throws Exception {
        String str1 = "java,mysql.spring;springboot";
        String[] arr = str1.split("\\W");
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}






















